<template>
	<view class="box">
		<uni-nav-bar background-color="#27a647"
		left-icon="left" color="white" 
		:title="movie.name" @clickLeft="comeback"></uni-nav-bar>
		<view class="movieHead" :style="{'backgroundImage':'url(http://172.21.63.114:10001'+movie.cover+')'}">
		</view>
		<view class="moviecontent">
			<div><img :src="'http://172.21.63.114:10001'+movie.cover" alt="" width="110rpx" height="150rpx"></div>
			<div class="jianjie">
				<p class="title">{{movie.name}}</p>
				<p>喜淘评分：<span style="color: gold;font-size: 30rpx;">{{movie.score}}</span></p>
				<p>语言：{{movie.language}}</p>
				<p>上映年份：{{year}}</p>
				<div class="wantSee">
					<div>
						<u--text prefixIcon="heart" 
						iconStyle="font-size: 19px;color:green;" 
						align="center"
						color="white" text="想看"></u--text>
					</div>
					<div>
						<u--text prefixIcon="checkmark-circle" 
						iconStyle="font-size: 19px;color:#ffc34b;" 
						align="center"
						color="#f4bb48"
						text="看过"></u--text>
					</div>
				</div>
			</div>
		</view>
		<view class="detail">
			<p>影片简介：</p>
			<p class="jj" v-html="movie.introduction"></p>
		</view>
		<view class="commentList">
			<div class="pltitle">
				<p>网友评论：</p>
				<u-button  class="fbtn" @click="handleSend">发表评论</u-button>
			</div>
			<u-read-more showHeight="1000" ref="uReadMore" :toggle="true">
				<view class="userList" v-for="(item,index) in commom" :key="index">
					<div>
						<u-image 
						src="https://cdn.uviewui.com/uview/album/1.jpg"
						shape="circle"
						width="80rpx" height="80rpx"
						 :lazy-load="true"></u-image>
					</div>
					<div>
						<div>
							<p>{{item.nickName}}</p>
							<p>
								<u-rate count="5"
								active-color="gold"
								minCount="1"
								readonly
								 v-model="item.score"></u-rate>
							</p>
							<p v-html="item.content"></p>
							<p>{{item.commentDate}}</p>
						</div>
						<div>
							<u--text prefixIcon="thumb-up" text="112"
							ref="dianzan"
							 @click="commomLike(item.id)"></u--text>
						</div>
					</div>
				</view>
			</u-read-more>
			
		</view>
		<u-popup :show="show" mode="bottom" closeable @close="close">
			<view class="plun">
				<h3>{{movie.name}}</h3>
				<div style="margin: 20rpx 0;">
					打分：<u-rate count="5" v-model="value"></u-rate>
				</div>
				<span style="padding: 10rpx 0 15rpx 0rpx;">评论:</span>
				<div class="textarea">
					<u--textarea v-model="value1" placeholder="请输入内容" ></u--textarea>
					<u-button style="margin-top: 20rpx;" 
					type="primary" text="发送"
					@click="sendPinglun"></u-button>
				</div>
			</view>	
			
		</u-popup>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				movie:{
					playDate:''
				},
				commom:[],
				show:false,
				value:'',
				value1:''
			};
		},
		onLoad(opt) {
			this.id=opt.movieId
			this.getMovieXq()
			this.getFilmCommonList()
			this.regetCommom()
		},
		methods:{
			regetCommom(){
				setTimeout(() => {
					this.$nextTick(() => {
						this.$refs.uReadMore.init();
					})
				}, 500);
			},
			comeback(){
				uni.navigateBack({
					delta: 1
				});
			},
			getMovieXq(){
				this.$request({
					url:'/prod-api/api/movie/film/detail/'+this.id,
					method:'GET',
				}).then(res=>{
					// console.log(res);
					this.movie=res.data.data
				}).catch(err=>{
					console.log(err);
				})
			},
			getFilmCommonList(){
				this.$request({
					url:'/prod-api/api/movie/film/comment/list',
					method:'GET',
					data:{movieId:this.id}
				}).then(res=>{
					// console.log('我被调用了',res);
					this.commom=res.data.rows
				}).catch(err=>{
					console.log(err);
				})
			},
			commomLike(id){
				this.$request({
					url:'/prod-api/api/movie/film/comment/like/'+id,
					method:'POST',
				}).then(res=>{
					if(res.data.code=="200"){
						uni.$u.toast("点赞成功")
					}
				}).catch(err=>{
					console.log(err);
				})
			},
			handleSend(){
				this.show=true
			},
			close(){
				this.show=false
			},
			sendPinglun(){
				this.$request({
					url:'/prod-api/api/movie/film/comment',
					method:'POST',
					data:{
						content:this.value1,
						movieId:this.id,
						score:this.value
					}
				}).then(res=>{
					console.log(res);
					if(res.data.code=="200"){
						uni.$u.toast("发送成功")
						this.getFilmCommonList()
						this.regetCommom()
					}
					this.show=false
				}).catch(err=>{
					console.log(err);
				})
				this.value="";
				this.value1=""
			}
		},
		computed:{
			year(){
				return this.movie.playDate.slice(0,4)
			}
		}
	}
</script>

<style lang="scss">
	$fontSize:28rpx;
.box{
	position: relative;
	.movieHead{
		padding-top: 88rpx;
		// background-color: rgba(0, 0, 0, 0.6);
		background-size: 100% 100%;
		filter:blur(4px)brightness(50%);
		height: 350rpx;
	}
	.moviecontent{
		// background-color: rgba(0, 0, 0, 0.8);
		position: absolute;
		top: 128rpx;
		left: 44rpx;
		height: 320rpx;
		display: flex;
		.jianjie{
			margin-left: 60rpx;
			color: white;
			font-size: 25rpx;
			.title{
				font-size: 70rpx;
				font-weight: 550;
				margin-bottom: 20rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
			}
			p{
				margin: 10rpx 0;
			}
			.wantSee{
				display: flex;
				
				div{
					width: 160rpx;
					height: 80rpx;
					margin: 0 20rpx 0 0;
					background-color: rgba(255, 255, 255, 0.2);
					line-height: 80rpx;
					text-align: center;
					border-radius: 20rpx;
					
				}
			}
		}
	}
	.detail{
		padding: 20rpx 15rpx;
		border-bottom: 15rpx solid rgba(244, 242, 244, 1.0);
		font-size: $fontSize;
		.jj{
			margin-top: 15rpx;
			line-height: 34rpx;
			font-size: 24rpx;
			/deep/span{
				color:grey;
			}
		}
	}
	.commentList{
		font-size: $fontSize;
		padding: 20rpx 15rpx;
		.pltitle{
			display: flex;
			border-bottom: 1px solid #e7e7e7;
			p{
				flex: 1;
			}
			.fbtn{
				margin-left: auto;
				width: 180rpx;
				height: 44rpx;
				color: #11ab09;
				border: 0;
			}
		}
		.userList{
			padding: 20rpx 15rpx;
			display: flex;
			text-indent:0rem;
			line-height: 30rpx;
			div:nth-child(2){
				display: flex;
				border-bottom:1px solid #e7e7e7;
				padding-bottom: 20rpx;
				position: relative;
				div:first-child{
					width: 500rpx;
					padding-left: 40rpx;
				}
				div:nth-child(2){
					width: 100rpx;
					position: absolute;
					bottom: -1px;
					right: 0;
				}
			}
		}
		
	}
	.plun{
		padding-top: 50rpx;
		padding-left: 20rpx;
		.u-rate{
			position: absolute;
			// top: -35rpx;
			top: 115rpx;
			left: 86rpx;
		}
		.textarea{
			padding: 5rpx 40rpx 0 0rpx;
		}
	}
}
</style>
